<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>项目供应商管理</title>
	<meta name="decorator" content="default"/>
	<link rel="stylesheet" href="${ctxStatic}/common/bootstrap.min.css">
	<link rel="stylesheet" href="${ctxStatic}/common/AdminLTE.min.css">
	<link rel="stylesheet" href="${ctxStatic}/common/jeesite.css">
	<script src="${ctxStatic}/jquery-validation/1.16/jquery.validate.js"></script>
	<script src="${ctxStatic}/jquery-validation/1.16/jquery.validate.extend.js"></script>
	<script src="${ctxStatic}/jquery-validation/1.16/localization/messages_zh_CN.js"></script>
	<style type="text/css">
		#inputForm a{
			height: 30px;
			border-color: #ccc;
		}
		
		#contentTable tr{
			font-size: 13px;
		}
		#contentTable th{
			border-left: 1px solid #ddd;
			border-top: 1px solid #ddd;
		}
		#contentTable td{
			border-left: 1px solid #ddd;
			border-top: 1px solid #ddd;
		}
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
			
			// 新增项目供应商
			$("#addBtn").click(function(){
				top.$.jBox.open("iframe:${ctx}/zx/proSupplier/addProSupplier?lzdId=${lzd.id}&sectionId=${lzd.ts.id}", "新增项目供应商", 1000, 400,{
					buttons:{"提交":"ok", "关闭":true}, bottomText:"",submit:function(v, h, f){
						//nodes = selectedTree.getSelectedNodes();
						if (v == "ok"){
							//debugger;
							var flag = h.find("iframe")[0].contentWindow.subForm();
							if(!flag){
								return false;
							}else{
								location.reload();
							}
							
						} 
					}, loaded:function(h){
						$(".jbox-content", top.document).css("overflow-y","hidden");
					}
				});
			});

			$("#btnSubmit").click(function(){
				top.$.jBox.open("iframe:${ctx}/zx/proSupplier/mySupplierList?lzdId=${lzd.id}&sectionId=${lzd.ts.id}", "选择供应商",1000,$(top.document).height()-240,{
					buttons:{"确定提交":"ok", "清除已选":"clear", "关闭":true}, bottomText:"",submit:function(v, h, f){
						//nodes = selectedTree.getSelectedNodes();
						if (v == "ok"){
							var ids = h.find("iframe")[0].contentWindow.getCheckVal();
							//console.log(ids);
							if(ids == null || ids == ""){
								top.$.jBox.tip("请勾选信息", 'info');
								return false;
							}
					    	// 执行保存
					    	loading('正在提交，请稍等...');
					    	$("#sIds").val(ids);
					    	$('#psRoleForm').submit();
					    	return true;
						} else if (v == "clear"){
							h.find("iframe")[0].contentWindow.clearCheck();
							return false;
		                }
					}, loaded:function(h){
						$(".jbox-content", top.document).css("overflow-y","hidden");
					}
				});
			});
		});
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/zx/proSupplier/">项目列表</a></li>
		<li class="active"><a href="${ctx}/zx/proSupplier/form?id=${lzd.id}&sectionId=${lzd.ts.id}">项目供应商<shiro:hasPermission name="zx:proSupplier:edit">设置</shiro:hasPermission><shiro:lacksPermission name="zx:proSupplier:edit">查看</shiro:lacksPermission></a></li>
	</ul>
	<div class="main-content">
	  <div class="box box-main">
	  	<form id="psRoleForm" action="${ctx}/zx/proSupplier/savePsRole" method="post" class="hide">
			<input id="sIds" name="sIds" type="hidden">
			<input value="${lzd.id}" name="lzdId" type="hidden">
			<input value="${lzd.ts.id}" name="sectionId" type="hidden">
			
		</form>
		 <form:form id="inputForm" modelAttribute="lzd" action="${ctx}/zx/proSupplier/saveBidMoney?type=${type}" method="post" class="form-horizontal">
			<form:hidden path="id"/>
			<input value="${lzd.ts.id}" name="sectionId" type="hidden">
			<sys:message content="${message}"/>	
			<div class="box-body">
				<div class="form-unit">项目基本信息
					<span style="float: right">
						<a href="${ctx}/zx/all/lzd/getLzdAllInfo?lzdId=${lzd.id}&sectionId=${lzd.ts.id}&pageFlag=proSupplier"> 查看更多项目详情>></a>
					</span>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 项目编码：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<form:input path="proNo" maxlength="100" class="form-control required" cssStyle="height:30px" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 项目名称：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<form:input path="proName" maxlength="100" class="form-control required" cssStyle="height:30px" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 采购单位：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<form:input path="buyUnit" maxlength="255" class="form-control" cssStyle="height:30px" disabled="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> 项目负责人：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<form:input path="proPic" maxlength="100" class="form-control" cssStyle="height:30px" disabled="true"/>
							</div>
						</div>
					</div>
				</div>
				<c:if test="${lzd.isSubpackage eq '2'}">
					<div class="row">
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> 项目预算(<font style="color: red">万元</font>)：<i class="fa icon-question hide"></i></label>
								<div class="col-sm-8">
									<form:input path="budgetMoney" maxlength="100" class="form-control" cssStyle="height:30px" disabled="true"/>
								</div>
							</div>
						</div>
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> 保证金：<i class="fa icon-question hide"></i></label>
								<div class="col-sm-8">
									<form:input path="depositMoney" maxlength="100" class="form-control" cssStyle="height:30px" disabled="true"/>
								</div>
							</div>
						</div>
					</div>
				</c:if>
				<!-- 标段信息 -->
				<c:if test="${lzd.isSubpackage eq '1'}">
					<div class="form-unit">标段信息</div>
					<div class="row">
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> 标段名称：<i class="fa icon-question hide"></i></label>
								<div class="col-sm-8">
									<form:input path="ts.sectionName" maxlength="100" class="form-control required" cssStyle="height:30px" disabled="true"/>
								</div>
							</div>
						</div>
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> 项目预算(<font style="color: red">万元</font>)：<i class="fa icon-question hide"></i></label>
								<div class="col-sm-8">
									<form:input path="ts.budgetMoney" maxlength="100" class="form-control" cssStyle="height:30px" disabled="true"/>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> 折扣：<i class="fa icon-question hide"></i></label>
								<div class="col-sm-8">
									<form:input path="ts.discount" maxlength="100" class="form-control required" cssStyle="height:30px" disabled="true"/>
								</div>
							</div>
						</div>
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> 保证金(<font style="color: red">万元</font>)：<i class="fa icon-question hide"></i></label>
								<div class="col-sm-8">
									<form:input path="depositMoney" maxlength="100" class="form-control" cssStyle="height:30px" disabled="true"/>
								</div>
							</div>
						</div>
					</div>
				</c:if>
				<div class="form-unit" style="margin-bottom: 10px;">项目供应商信息</div>
				<shiro:hasPermission name="zx:proSupplier:edit">
					<div style="padding-bottom: 10px;padding-left: 10px">
						<!-- <input id="btnSubmit" class="btn btn-primary btn-xs" type="button" value="选择项目供应商"/> -->
						<input id="addBtn" class="btn btn-success btn-xs" type="button" value="新增项目供应商"/>
					</div>
				</shiro:hasPermission>
				<table id="contentTable" class="table table-striped table-bordered table-condensed">
					<thead>
						<tr>
							<th>单位名称</th>
							<th>联络人</th>
							<th>联系电话</th>
							<th>中标金额</th>
							<shiro:hasPermission name="zx:proSupplier:edit"><th>操作</th></shiro:hasPermission>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${psList}" var="ps" varStatus="vs">
							<tr>
								<td>${ps.supplier.name}</td>
								<td>${ps.supplier.contacts}</td>
								<td>${ps.supplier.phone}</td>
								<%-- <td>${ps.supplier.address}</td> --%>
								<c:if test="${type eq '1'}">
									<td>
										${ps.bidMoney}
									</td>
								</c:if>
								<c:if test="${type eq '2'}">
									<td>
										<div style="position: relative;">
											<input type="hidden" name="psList[${vs.index}].id" value="${ps.id}">
											<input name="psList[${vs.index}].bidMoney" value="${ps.bidMoney}" maxlength="100" class="form-control number zx-input" style="height:30px;width: 150px;border-radius: 4px;"/>						
										</div>
									</td>
								</c:if>
								
								<shiro:hasPermission name="zx:proSupplier:edit"><td>
				    				<a href="${ctx}/zx/proSupplier/delete?id=${ps.id}&lzdId=${ps.lzdId}&sectionId=${lzd.ts.id}" onclick="return confirmx('确认要移除吗？', this.href)">移除该供应商</a>
								</td></shiro:hasPermission>
							</tr>
						</c:forEach>
					</tbody>
				</table>				
				<div class="form-actions" style="background-color: #fff;padding-left: 0px">
					<c:if test="${fn:length(psList) > 0}">
						<c:if test="${type eq '2'}">
							<input class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
						</c:if>
						
					</c:if>
					<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)" style="background-color: #e7e7e7;"/>
				</div>
			</div>	
		 </form:form>
	  </div>
	</div>
</body>
</html>